package clientText;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;

public class InterNetClint_2 {

	public static void main(String[] args) throws IOException, IOException {
		Socket s = new Socket("172.21.12.251",9700);
		Thread t1 = new Thread(){
			public void run(){
				InputStream is;
				try {
					is = s.getInputStream();
					Scanner sc = new Scanner(is);
					while(true){
						System.out.println(sc.nextLine());
					}
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		};
		Thread t2 = new Thread(){
			public void run(){
				Scanner sc = new Scanner(System.in);
				OutputStream os;
				try {
					os = s.getOutputStream();
					PrintWriter pw = new PrintWriter(os,true);
					while(true){
						String s = sc.nextLine();
						pw.println(s);
					}
				} catch (IOException e) {
					e.printStackTrace();
				}

			}
		};
		t1.start();
		t2.start();

	}

}
